package demo.common.entity;

import lombok.*;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;

/**
 * 通用复杂类(所谓复杂，指的是包含了一些没有构造器的jdk1.8新增类比如LocalDateTime，因为这些新增类对很多框架的解析或者判断都产生了影响)
 *
 * @author yexi
 */
@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommonComplexEntity extends CommonEntity {
    private LocalDateTime dateTime;

    public CommonComplexEntity(Number number, String description, Date createTime, Map<Object, Object> objMap, LocalDateTime dateTime) {
        this.setNumber(number);
        this.setDescription(description);
        this.setCreateTime(createTime);
        this.setObjMap(objMap);
        this.dateTime = dateTime;
    }

    public CommonComplexEntity(String description, Date createTime, Map<Object, Object> objMap, LocalDateTime dateTime) {
        this.setDescription(description);
        this.setCreateTime(createTime);
        this.setObjMap(objMap);
        this.dateTime = dateTime;
    }

    public static CommonComplexEntity buildTestData() {
        CommonComplexEntity commonEntity = new CommonComplexEntity(BigDecimal.valueOf(34.65), "描述", new Date(), Collections.singletonMap("key", true), LocalDateTime.now());
        return commonEntity;
    }

    public static List<CommonComplexEntity> buildTestComplexDataList() {
        CommonComplexEntity ce1 = new CommonComplexEntity(BigDecimal.valueOf(34.65), "描述", new Date(), Collections.singletonMap("key", true), LocalDateTime.now());
        CommonComplexEntity ce2 = new CommonComplexEntity("描述2", new Date(), Collections.singletonMap("skey", false), LocalDateTime.now());
        List<CommonComplexEntity> list = new ArrayList<>();
        list.add(ce1);
        list.add(ce2);
        return list;
    }


}
